package com.zh.juc.completablefuture;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author: zhanghuan
 * @date: 2022/10/6 13:41
 * @description: create it
 */
public class CompleteableFutureDemo {
    public static void main(String[] args) {
        FutureTask<String> futureTask = new FutureTask<>(new MyThread());
        Thread t1 = new Thread(futureTask, "t1");
        t1.start();
        try {
            String s = futureTask.get();
            System.out.println(s);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }

}


class MyThread implements Callable<String> {

    @Override
    public String call() throws Exception {
        System.out.println("come in");
        return "hello,callable";
    }
}